Clover coverage report - Enterprise Web Services - 1.0
Coverage timestamp: Mon May 30 2005 17:10:32 CEST
file stats: LOC: 152   Methods: 7
NCLOC: 112   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
InternalBasedWrapperClassWriter.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * Copyright 2001-2004 The Apache Software Foundation.
 3   
  * 
 4   
  * Licensed under the Apache License, Version 2.0 (the "License");
 5   
  * you may not use this file except in compliance with the License.
 6   
  * You may obtain a copy of the License at
 7   
  * 
 8   
  *      http://www.apache.org/licenses/LICENSE-2.0
 9   
  * 
 10   
  * Unless required by applicable law or agreed to in writing, software
 11   
  * distributed under the License is distributed on an "AS IS" BASIS,
 12   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13   
  * See the License for the specific language governing permissions and
 14   
  * limitations under the License.
 15   
  */
 16   
 
 17   
 package org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs.geronimo;
 18   
 
 19   
 import org.apache.commons.logging.Log;
 20   
 import org.apache.commons.logging.LogFactory;
 21   
 import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
 22   
 import org.apache.geronimo.ews.ws4j2ee.context.SEIOperation;
 23   
 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
 24   
 import org.apache.geronimo.ews.ws4j2ee.toWs.JavaClassWriter;
 25   
 import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
 26   
 
 27   
 import java.util.ArrayList;
 28   
 import java.util.Iterator;
 29   
 
 30   
 /**
 31   
  * @author Srinath Perera(hemapani@opensource.lk)
 32   
  */
 33   
 public class InternalBasedWrapperClassWriter extends JavaClassWriter {
 34   
     protected static Log log =
 35   
             LogFactory.getLog(InternalBasedWrapperClassWriter.class.getName());
 36   
     protected final String seiName;
 37   
     protected final String ejbName;
 38   
 
 39   
     /**
 40   
      * @param j2eewscontext
 41   
      * @param qulifiedName
 42   
      * @throws GenerationFault
 43   
      */
 44  0
     public InternalBasedWrapperClassWriter(J2EEWebServiceContext j2eewscontext)
 45   
             throws GenerationFault {
 46  0
         super(j2eewscontext, getName(j2eewscontext) + "Impl");
 47  0
         seiName = j2eewscontext.getMiscInfo().getJaxrpcSEI();
 48  0
         ejbName = j2eewscontext.getEJBDDContext().getEjbName();
 49   
     }
 50   
 
 51  0
     private static String getName(J2EEWebServiceContext j2eewscontext) {
 52  0
         String name =
 53   
                 j2eewscontext.getWSDLContext().gettargetBinding().getName();
 54  0
         if (name == null) {
 55  0
             name = j2eewscontext.getMiscInfo().getJaxrpcSEI();
 56   
         }
 57  0
         return name;
 58   
     }
 59   
 
 60  0
     protected String getimplementsPart() {
 61  0
         return " implements " + j2eewscontext.getMiscInfo().getJaxrpcSEI() + "," + "org.apache.geronimo.ews.ws4j2ee.wsutils.ContextAccessible";
 62   
     }
 63   
 
 64  0
     protected void writeAttributes() throws GenerationFault {
 65  0
         out.write("private org.apache.axis.MessageContext msgcontext;\n");
 66  0
         out.write("\tprivate " + seiName + " bean = null;\n");
 67  0
         out.write("\tprivate org.openejb.EJBContainer container;\n");
 68   
     }
 69   
 
 70  0
     protected void writeConstructors() throws GenerationFault {
 71  0
         out.write("\tpublic " + classname + "(){\n");
 72  0
         out.write("\t}\n");
 73   
     }
 74   
 
 75  0
     protected void writeMethods() throws GenerationFault {
 76  0
         out.write("\tpublic void setMessageContext(org.apache.axis.MessageContext msgcontext){;\n");
 77  0
         out.write("\t\tthis.msgcontext = msgcontext;\n");
 78  0
         out.write("\t}\n");
 79  0
         String parmlistStr = null;
 80  0
         ArrayList operations = j2eewscontext.getMiscInfo().getSEIOperations();
 81  0
         for (int i = 0; i < operations.size(); i++) {
 82  0
             parmlistStr = "";
 83  0
             SEIOperation op = (SEIOperation) operations.get(i);
 84  0
             String returnType = op.getReturnType();
 85  0
             if (returnType == null)
 86  0
                 returnType = "void";
 87  0
             out.write("\tpublic " + returnType + " " + op.getMethodName() + "(");
 88  0
             Iterator pas = op.getParameterNames().iterator();
 89  0
             boolean first = true;
 90  0
             while (pas.hasNext()) {
 91  0
                 String name = (String) pas.next();
 92  0
                 String type = op.getParameterType(name);
 93  0
                 if (first) {
 94  0
                     first = false;
 95  0
                     out.write(type + " " + name);
 96  0
                     parmlistStr = parmlistStr + name;
 97   
                 } else {
 98  0
                     out.write("," + type + " " + name);
 99  0
                     parmlistStr = parmlistStr + "," + name;
 100   
                 }
 101   
             }
 102  0
             out.write(") throws java.rmi.RemoteException");
 103  0
             ArrayList faults = op.getFaults();
 104  0
             for (int j = 0; j < faults.size(); j++) {
 105  0
                 out.write("," + (String) faults.get(i));
 106   
             }
 107  0
             out.write("{\n");
 108  0
             out.write("\t\tString methodName = \"" + op.getMethodName() + "\";\n");
 109  0
             out.write("\t\tjava.lang.reflect.Method callMethod = Utils.getJavaMethod(\""
 110   
                     + seiName
 111   
                     + "\",methodName);\n");
 112  0
             out.write("\t\tClass[] classes = callMethod.getParameterTypes();\n");
 113  0
             out.write("\t\tObject[] arguments = new Object[]{");
 114  0
             pas = op.getParameterNames().iterator();
 115  0
             first = true;
 116  0
             while (pas.hasNext()) {
 117  0
                 String name = (String) pas.next();
 118  0
                 String type = op.getParameterType(name);
 119  0
                 if (first) {
 120  0
                     first = false;
 121  0
                     out.write(Utils.getParameter(type, name));
 122   
                 } else {
 123  0
                     out.write("," + Utils.getParameter(type, name));
 124   
                 }
 125   
             }
 126  0
             out.write("};\n");
 127  0
             if (!"void".equals(returnType)) {
 128  0
                 out.write("\t\t\treturn "
 129   
                         + Utils.getReturnCode(returnType, "AxisGeronimoUtils.invokeEJB(\""
 130   
                         + ejbName
 131   
                         + "\",methodName,classes,arguments)")
 132   
                         + ";\n");
 133   
             } else {
 134  0
                 out.write("\t\t\tAxisGeronimoUtils.invokeEJB(\""
 135   
                         + ejbName
 136   
                         + "\",methodName,classes,arguments);\n");
 137   
             }
 138  0
             out.write("\t}\n");
 139   
         }
 140   
     }
 141   
 
 142   
     /* (non-Javadoc)
 143   
      * @see org.apache.geronimo.ews.ws4j2ee.toWs.JavaClassWriter#writeImportStatements()
 144   
      */
 145  0
     protected void writeImportStatements() throws GenerationFault {
 146  0
         out.write("import org.apache.geronimo.axis.AxisGeronimoUtils;\n");
 147  0
         out.write("import org.apache.geronimo.ews.ws4j2ee.utils.Utils;\n");
 148   
     }
 149   
 
 150   
 }
 151   
 
 152